import {Injector, provide, Provider, Injectable, Inject} from 'angular2/src/core/di';
import {Console} from 'angular2/src/core/console';

// var messageProvider = new Provider("message", { useValue: 'Hello' });
// var injector = Injector.resolveAndCreate([
// 	messageProvider
// ]);
// console.log(injector.get("message"));
// console.log(injector.displayName);

export class Engine {
  public cylinders = 4; // default
}

export class Tires {
  public make  = 'Flintstone';
  public model = 'Square';
}

// @Injectable()
export class Car {
  public description = 'No DI';
  constructor(@Inject(Engine) public engine: Engine, @Inject(Tires) public tires: Tires) {
//   constructor(public engine: Engine, public tires: Tires) {
  }
  // Method using the engine and tires
  drive() {
    return `${this.description} car with ` +
      `${this.engine.cylinders} cylinders and ${this.tires.make} tires.`
  }
}

var injector = Injector.resolveAndCreate([
	provide(Car, {useClass:Car}),
	provide(Engine, {useClass:Engine}),
	provide(Tires, {useClass:Tires})
]);


var car = injector.get(Car);
console.log(car.drive());